/*
 * UserInterface.h
 *
 *  Created on: 28.04.2009
 *      Author: h3llfire
 */

#ifndef USERINTERFACE_H_
#define USERINTERFACE_H_

#include "../../core/interfaces/iUserInterface.h"
#include "../../core/events/ImppCommandEvent.h"
#include "CustomMenu.h"
#include "Icons.h"

namespace Impp {

#define STD_USERINTERFACE_MODULE_NAME_BUDDY							wxT("StdUserInterfaceBuddy")
#define STD_USERINTERFACE_MODULE_NAME_MAIN							wxT("StdUserInterfaceMain")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_RENAME				wxT("buddyRename")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_CHECK_STATUS			wxT("buddyCheckStatus")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_ALLWAYS_VISIBLE		wxT("buddyAllwaysVisible")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_ALLWAYS_INVISIBLE		wxT("buddyAllwaysInvisible")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_IGNORE				wxT("buddyIgnore")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_PRIORITY_NORMAL		wxT("buddyPriorityNormal")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_PRIORITY_HIGH			wxT("buddyPriorityHigh")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_PRIORITY_LOW			wxT("buddyPriorityLow")

#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_SUBMENU_VISIBILITY	wxT("buddySubmenuVisbility")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_SUBMENU_PRIORITY		wxT("buddySubmenuPriority")
#define STD_USERINTERFACE_MODULE_ACTION_BUDDY_SUBMENU_MOVE			wxT("buddySubmenuMove")

#define STD_USERINTERFACE_MODULE_ACTION_MAIN_ABOUT					wxT("mainAbout")
#define STD_USERINTERFACE_MODULE_ACTION_MAIN_EXIT					wxT("mainExit")

class UserInterface : wxEvtHandler {

private:
	CustomMenu* buddyMenu;
	CustomMenu* mainMenu;
	Icons* icons;

public:
	UserInterface();
	virtual ~UserInterface();

	virtual void moduleInit();
	virtual void moduleDestroy();

	void buildChooseStatusMenu(wxMenu* menu, Account* account, bool invisible);
	void buildBuddyMenu(wxMenu* menu, Buddy* buddy);
	void buildGroupMenu(wxMenu* menu, Group* group);
	void buildMainMenu(wxMenu* menu);

	void reigsterBuddyMenuEntryAdder(const wxString & moduleName, addBuddyMenuItemCallback callback);
	void reigsterMainMenuEntryAdder(const wxString & moduleName, addMenuItemCallback callback);

	iIcons* getIcons();

	virtual bool showFirstRunWizzard();

	static Account* showChooseAccountDialog(const wxString & title, const wxString & description);

private:
	void onImppCommand(ImppCommandEvent & event);


	void onMainMenuItem(wxCommandEvent & event);

	static void wxCALLBACK addStdBuddyMenuEntries(iMenu* menu, Buddy* userData);
	static void wxCALLBACK addStdMainMenuEntries(iMenu* menu, void* userData);

	void addStatusMenuItem(wxMenu* menu, int id, Status status);

};

class StdUserInterfaceModule: public iUserInterface {

	DECLARE_DYNAMIC_CLASS(StdUserInterfaceModule)

private:
	UserInterface* ui;
public:
	StdUserInterfaceModule() :
		ui(NULL){};

	virtual ~StdUserInterfaceModule(){};

	virtual void moduleInit(){
		ui = new UserInterface();
		ui->moduleInit();
	}
	virtual void moduleDestroy(){
		ui->moduleDestroy();
		wxDELETE(ui);
	}

	void buildChooseStatusMenu(wxMenu* menu, Account* account, bool invisible){
		ui->buildChooseStatusMenu(menu, account, invisible);
	}

	virtual bool showFirstRunWizzard(){
		return ui->showFirstRunWizzard();
	}

	void buildBuddyMenu(wxMenu* menu, Buddy* buddy){
		ui->buildBuddyMenu(menu, buddy);
	}
	void buildGroupMenu(wxMenu* menu, Group* group){
		ui->buildGroupMenu(menu, group);
	}
	void buildMainMenu(wxMenu* menu){
		ui->buildMainMenu(menu);
	}

	void reigsterBuddyMenuEntryAdder(const wxString & moduleName, addBuddyMenuItemCallback callback){
		ui->reigsterBuddyMenuEntryAdder(moduleName,callback);
	}

	void reigsterMainMenuEntryAdder(const wxString & moduleName, addMenuItemCallback callback){
		ui->reigsterMainMenuEntryAdder(moduleName,callback);
	}

	iIcons* getIcons(){
		return ui->getIcons();
	}

};

}

#endif /* USERINTERFACE_H_ */
